/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package imPro;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 *
 * @author Ragnar
 */
public class BeagleServer
{
    ServerSocket sSocket;
    Socket iSocket;
    BufferedReader sInputReader;
    ObjectInputStream sInputStream;
    ObjectOutputStream sOutputStream;
    Common src;
    
    public BeagleServer()
    {
        src = new Common();
        CamCapture cc = new CamCapture(src);
        
        try
        {
            ServerSocket serverSocket = new ServerSocket(4444);
            System.out.println("Server ready, running on port 4444.");
            
            while (true)
            {
                Socket socket = serverSocket.accept();
                InetAddress inetAddress = socket.getInetAddress();
                System.out.println("Host " + inetAddress.getHostName() + " has connected!");
                HandleClient task = new HandleClient(socket, this.src);
                new Thread(task).start();
            }
        }
        catch (IOException e)
        {
            System.err.println(e.getMessage());
        }
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {        
        new BeagleServer();
    }   
}